<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自然堂</title>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"
          id="viewport"/>
    <link rel="stylesheet" href="${rc.contextPath}/htdocs/jweb/css/reset.css"/>
    <link rel="stylesheet" href="${rc.contextPath}/htdocs/jweb/css/login.css"/>
    <script src="${rc.contextPath}/htdocs/jweb/js/jquery-2.1.1.min.js"></script>
</head>
<body>
<div class="loginbg">
    <header>
        <div class="logo">
            <h1>自然堂</h1>
        </div>
        <div class="login">
            <!--<div class="loginbg">-->
            <p class="loginy">门店登录验证</p>
            <div class="username">
                <div class="usernamelist">
                    <!--<input placeholder="店铺名称" type="text" value="$!{shopInfo.shopName}" class="uname" disabled/>-->
                    <p class="uname">$!{shopInfo.shopName}</p>
                </div>
            </div>
            <div class="userid">
                <div class="useridlist">
                    <!--<input placeholder="店铺编码" type="text" value="$!{shopInfo.dealerName}" class="uid" disabled/>-->
                    <p class="uid">$!{shopInfo.dealerName}</p>
                </div>
            </div>
            <div class="userpass">
                <div class="userpasslist">
                    <input type="text" name="username" value="123" id="username" hidden/>
                    <input type="text" name="qrCodeMsg" value="$!{qrCodeMsg}" id="qrCodeMsg" hidden/>
                    <input placeholder="登录密码" id="password" type="password" name="password" value="" class="upass"/>
                </div>
            </div>
            <div class="usersub">
                <button id="usersub" class="usersubmit" onclick="toVaild();">登录</button>
            </div>
        </div>
    </header>
    <section class="passperbg"></section>
    <div class="mask"></div>
    <section class="sucess">
        <div class="sucessgo">
            <p class="alt_info">不能为空</p>
            <div class="clo"></div>

        </div>
    </section>
</div>
</div>
<script type="text/javascript">


    function set(){
        var w = document.documentElement.clientWidth;
        if(w > 667){
            w = 667;
        }else if(w < 320){
            w = 320;
        }
        var rate = w / 667;
        document.documentElement.style.fontSize = 40 * rate + "px";
    }
    set();
    window.onresize = set;

    var oMask = $('.mask');
    var oModal = $('.sucess');
    var oClose = $('.clo');
    var upassperbg = $('.passperbg');
    function modalShow(arg) {
        oMask.css('display', 'block');
        oModal.css('display', 'block');
        upassperbg.css('display','block');
        $('.alt_info').html(arg);
        $('.mask,.clo').click(function () {
            upassperbg.css('display','none');
            oMask.css('display', 'none');
            oModal.css('display', 'none');
        })
    };

    function loginValid() {
        var password = $("#password").val();
        if ($.trim(password) == "") {
            modalShow('请输入密码！')
            return false;
        }
        return true;
    }

    $(document).ready(function () {
        if ($("#qrCodeMsg").val() != "") {
//            alert($("#qrCodeMsg").val());
            modalShow($("#qrCodeMsg").val())
            return
        }
    });


    function toVaild() {
        if (loginValid()) {
            $.ajax({
                type: "POST",
                url: "${rc.contextPath}/wx/login.htm",
                data: {"username": $("#username").val(), "password": $("#password").val()},
                async: false,
                dataType: "json",
                success: function (data) {
                    if (data.code != "0") {
                        modalShow('密码错误！')
                    } else {
                        window.location.href = "${rc.contextPath}/wx/index.htm";
                    }

                },
                error: function (data) {
                    modalShow('系统发生异常!');
                }
            });
        }

    }
</script>
</body>
</html>
